In this How To we are going to build SDL 1.2.15 with our GCC/G++ 4.8.2 cross-compiler. Be sure to start this build in a new terminal/tab to avoid any pollution from previous builds. I really enjoy using SDL because it's easy to learn, has a lot of features and we do not need to use X for writing graphics to the screen or for handling keyboard and mouse envents. Why, you may ask, do I not care for X? It's not so much that I hate it, its that X can be a little resource hungry, and most of all it has *a lot* of dependencies. Which makes it a burden to cross-compile. But don't let that discourage you from trying ;-) When I first started to play with SDL I tried the newer version, SDL 2.0, but was not having luck using my SDL 2.0 based programs with the Linux framebuffer. I read that SDL 2.0 dropped support for the Linux framebuffer out of the box. Instead it sounds like they use various third party libraries to accomplish that task, which to me means more dependencies that I would need to build :| Programming Linux Games is a great book for getting up to speed with SDL. Here is a interesting Linux distro that uses SDL and AGAR for playing SDL based games and much more.
Tar Balls
Here is a list of source packages that we'll need for the build. You can either download them now or wait 'til later in the How To.
SDL-1.2.15.tar.gz
Create a Workspace
I recommend creating a workspace under your /home/<your user>/ directory that is dedicated to this build. So let's fire up your terminal and run the following:
NOTE: Depending on whether you are using a cross-compiler built from my other wikis you might need to change INSTALLDIR to point to your cross-compiler.
Build SDL
$ cd ../build/
$ ../src/SDL-1.2.15/./configure --prefix=/home/<your user>/workbench/sdl/final --host=$TARGETMACH --disable-static --disable-pulseaudio
!!! Need to modify the Makefile !!!
Change:
EXTRA_LDFLAGS = -lm -ldl -L/usr/lib/x86_64-linux-gnu -ldirectfb -lfusion -ldirect -lpthread -lpthread
To:
EXTRA_LDFLAGS = -lm -ldl -lpthread -lrt
$ make
$ make install
NOTE: I had to make the above changes for it to work for me, but you might not have to. First try the build without making the above changes to the Makefile. If it fails then try the above. Also, notice that I'm running on a 64-bit machine (builder).
Output
cd into the final directory and output its contents:
$ cd ../final/
$ ls
You should have the following directories:
bin
include
lib
share
Lastly, move the contents of these directories, or the directories themselves if they do not already exist, to your custom Linux file system or dev board. For SDL, the files should go under /usr.
Usage
To use SDL all you need to do is set the following in a new terminal/tab:
NOTE: Depending on whether you are using a cross-compiler built from my other wikis you might need to change INSTALLDIR to point to your cross-compiler.
When you're ready to cross-compile your SDL program:
How To Build SDL 1.2 for ARM
Intro
In this How To we are going to build SDL 1.2.15 with our GCC/G++ 4.8.2 cross-compiler. Be sure to start this build in a new terminal/tab to avoid any pollution from previous builds. I really enjoy using SDL because it's easy to learn, has a lot of features and we do not need to use X for writing graphics to the screen or for handling keyboard and mouse envents. Why, you may ask, do I not care for X? It's not so much that I hate it, its that X can be a little resource hungry, and most of all it has *a lot* of dependencies. Which makes it a burden to cross-compile. But don't let that discourage you from trying ;-) When I first started to play with SDL I tried the newer version, SDL 2.0, but was not having luck using my SDL 2.0 based programs with the Linux framebuffer. I read that SDL 2.0 dropped support for the Linux framebuffer out of the box. Instead it sounds like they use various third party libraries to accomplish that task, which to me means more dependencies that I would need to build :| Programming Linux Games is a great book for getting up to speed with SDL. Here is a interesting Linux distro that uses SDL and AGAR for playing SDL based games and much more.
Tar Balls
Here is a list of source packages that we'll need for the build. You can either download them now or wait 'til later in the How To.
Create a Workspace
I recommend creating a workspace under your /home/<your user>/ directory that is dedicated to this build. So let's fire up your terminal and run the following:
Gather the Sources
Now that we have a workspace created and we are currently in the src directory we can begin bringing down the sources and extracting them.
sdl
Build Environment
To make things a little smoother let's setup some environment variables:
$ export INSTALLDIR=~/workbench/gcc-g++-4.8.2/arm $ export PATH=$INSTALLDIR/bin:$PATH $ export TARGETMACH=arm-none-linux-gnueabi $ export BUILDMACH=i686-pc-linux-gnu $ export CROSS=arm-none-linux-gnueabi $ export CC=${CROSS}-gcc $ export LD=${CROSS}-ld $ export AS=${CROSS}-as $ export CXX=${CROSS}-g++NOTE: Depending on whether you are using a cross-compiler built from my other wikis you might need to change INSTALLDIR to point to your cross-compiler.Build SDL
NOTE: I had to make the above changes for it to work for me, but you might not have to. First try the build without making the above changes to the Makefile. If it fails then try the above. Also, notice that I'm running on a 64-bit machine (builder).
Output
cd into the final directory and output its contents:
You should have the following directories:
Lastly, move the contents of these directories, or the directories themselves if they do not already exist, to your custom Linux file system or dev board. For SDL, the files should go under /usr.
Usage
To use SDL all you need to do is set the following in a new terminal/tab:
$ export INSTALLDIR=~/workbench/gcc-g++-4.8.2/arm $ export PATH=$INSTALLDIR/bin:$PATH $ export TARGETMACH=arm-none-linux-gnueabi $ export BUILDMACH=i686-pc-linux-gnu $ export CROSS=arm-none-linux-gnueabi $ export CC=${CROSS}-gcc $ export LD=${CROSS}-ld $ export AS=${CROSS}-as $ export CXX=${CROSS}-g++NOTE: Depending on whether you are using a cross-compiler built from my other wikis you might need to change INSTALLDIR to point to your cross-compiler.When you're ready to cross-compile your SDL program:
If the above does not work, then try: